/*
 * Copyright (c) 2021. Moses All Right Reserved
 */

package com.moses.design_patterns.builder.inner_static_builder;

/**
 * @author Moses
 * @email shenhuohui@gmail.com
 * @date 2021/4/10 11:16
 */
public class Product {
    private int prop1;
    private double prop2;

    public void run(){
        System.out.println(this.toString());
    }

    // 采用静态内部类来构造外部类
    static class Builder{
        private Product product = new Product();

        protected Builder setProp1(int prop1){
            product.prop1 = prop1;
            return this;
        }

        protected Builder setProp2(double prop2){
            product.prop2 = prop2;
            return this;
        }

        public Product build(){
            return product;
        }
    }

    @Override
    public String toString() {
        return "Product{" +
                "prop1=" + prop1 +
                ", prop2=" + prop2 +
                '}';
    }
}
